<template>
  <div>
    <!-- 面包屑导航条 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>权限管理</el-breadcrumb-item>
      <el-breadcrumb-item>币种列表</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card>
      <el-row>
        <!--工具条-->
      </el-row>

      <el-table
        ref="multipleTable"
        :data="userlist"
        border
        stripe
        style="width: 100%"
        @sort-change="changeSort"
        id="out-table"
        tooltip-effect="dark"
        @selection-change="handleSelectionChange"
      >
        <el-table-column type="index"> </el-table-column>
        <el-table-column prop="coinName" label="币种名称"></el-table-column>

        <el-table-column label="价格">
          <template slot-scope="scope">
            <el-input
              v-model="scope.row.price"
              placeholder="请输入价格"
            ></el-input>
          </template>
        </el-table-column>

        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button
              type="primary"
              size="mini"
              @click="showEditJiefeng(scope.row)"
              >保存</el-button
            >
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>
<script>
export default {
  name: "realList",
  data() {
    return {
      searchfrom: {
        queryString: "",
        queryType: 0,
        pageNo: 1,
        pageSize: 10,
      },
      userlist: [],
    };
  },
  created() {
    this.getuserlist();
  },
  methods: {
    searchDrow(e) {
      console.log(e);
      this.searchfrom.queryType = e;
      this.searchfrom.pageNo = 1;
      this.getuserlist();
    },
    showEditJiefeng(item) {
  
      this.$confirm('确定修改币种价格？', "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$http
            .post("/manage/conf/coinPrice", item)
            .then((res) => {
              // console.log(res)
              if (res.data.status == 1) {
                this.$message({
                  message: '修改成功',
                  type: "success",
                });

                this.getuserlist();
              }
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消",
          });
        });
    },

    getuserlist() {
      this.$http.post("/manage/conf/coinList", this.searchfrom).then((res) => {
        // console.log(res)
        if (res.data.status == 1) {
          this.userlist = res.data.data;
        }
      });
    },
    searchUserList() {
      this.searchfrom.createDate = this.formatTime(this.value1);
      this.searchfrom.pageNo = 1;
      this.getuserlist();
    },
    // 监听 pagesize 的变化
    handleSizeChange(newSize) {
      // 把最新的 pagesize 赋值给 this.queryinfo
      this.searchfrom.pageSize = newSize;
      this.getuserlist();
    },
    // 监听 页码值 的变化
    handleCurrentChange(newPageNum) {
      console.log(newPageNum);
      this.searchfrom.pageNo = newPageNum;
      this.getuserlist();
    },
  },
};
</script>
